package com.china08.yxyapi.api.manage.stu.mystudy.mistakes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.service.mg.impl.StuVipWeikeViewServiceImpl;

/**
 * 观看微课的免费次数减一
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class StuMistakesFreeTimesController extends YxyApiBaseController {

    @Autowired
    private StuVipWeikeViewServiceImpl stuVipWeikeViewServiceImpl;

    @RequestMapping(value = "/api_yw/manage/stu/mystudy/mistake/free/times", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel reqModel) {

        String stuId = reqModel.stuId;
        RespModel model = new RespModel();
        model.freeTimes = stuVipWeikeViewServiceImpl.stuVipValidate(stuId);
        return model;
    }

    /* 请求参数 */
    protected static class ReqModel extends YxyApiReqModel {

        // 用户id
        public String stuId;
    }

    /* 响应参数 */
    protected static class RespModel extends YxyApiRespModel {

        public Integer freeTimes;
    }

}
